#include <iostream>
//抽象产品
class AbstractProduct {
public:
    virtual void show() = 0;
};

//抽象产品族1：KeyBoard
class KeyBoard : public AbstractProduct { };

//具体产品
class LogiKeyBoard : public KeyBoard {
public:
    void show() override {
        std::cout << "logi keyboard" << std::endl;
    }
};

class RazerKeyBoard : public KeyBoard {
public:
    void show() override {
        std::cout << "razer keyboard" << std::endl;
    }
};

//抽象产品族2：Mouse
class Mouse : public AbstractProduct { };

class LogiMouse : public Mouse {
public:
    void show() override {
        std::cout << "logi mouse" << std::endl;
    }
};

class RazerMouse : public Mouse { 
public:
    void show() override {
        std::cout << "razer mouse" << std::endl;
    }
};

//抽象工厂
class AbstractFactory { 
public:
    virtual KeyBoard* createKeyBoard() = 0;
    virtual Mouse* createMouse() = 0;
};

//具体工厂
class LogiFactory : public AbstractFactory {
public:
    KeyBoard* createKeyBoard() override {
        return new LogiKeyBoard;
    }
    Mouse* createMouse() override {
        return new LogiMouse;
    }
};

class RazerFactory : public AbstractFactory {
public:
    KeyBoard* createKeyBoard() override {
        return new RazerKeyBoard;
    }
    Mouse* createMouse() override {
        return new RazerMouse;
    }
};

int main(int argc, char const *argv[]) {
    AbstractFactory* factory = new LogiFactory;
    KeyBoard* kb = factory->createKeyBoard();
    kb->show();
    delete factory;
    factory = new RazerFactory;
    Mouse* m = factory->createMouse();
    m->show();
    return 0;
}